home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / AmigaTalk_X / system / MsgPort.st < prev    next >
Encoding:
Text File  |  2002-03-13  |  2.0 KB  |  58 lines

  1. "---------------------------------------------------------------------"
  2. " MsgPort Class allows the User to communicate using MsgPorts, either "
  3. " within AmigaTalk programs, or to any defined MsgPort known to Exec. "
  4. ""
  5. "   WARNING!  WARNING!  Danger, Will Robinson!                        "
  6. "   You had better know what size & what Message any outside System   "
  7. "   MsgPort expects to see & respond to!                              "
  8. "---------------------------------------------------------------------"
  9.  
  10. Class MsgPort :Object  ! private portName !
  11. [
  12.    killPort
  13.       <primitive 191 0 private>.
  14.       private <- nil              "One-way ticket to death!"
  15. |
  16.    addPort: msgSize priority: priority
  17.       " Add the MsgPort to the AmigaOS System PortList.  Use new: first! "
  18.       
  19.       (<primitive 191 1 private msgSize priority>)
  20.       
  21.         ifNil: [ self error: 'MsgPort ', portName, ' NOT added to System!'.
  22.                  ^ false
  23.                ].
  24.       ^ true
  25. |
  26.    getMessage
  27.       " If no message ever gets sent, you'll freeze AmigaTalk!! "
  28.       ^ <primitive 191 2 private> "Return an array of bytes."
  29. |
  30.    sendMessage: bytesArray
  31.       <primitive 191 3 private bytesArray>
  32. |
  33.    sendMessageOutsideTo: systemPortObj msg: bytesArray size: msgSize
  34.       " Send a message to a MsgPort outside the AmigaTalk System.
  35.       * WARNING!  WARNING!  Danger, Will Robinson!
  36.       * You had better know what size & what Message the port expects!
  37.       "
  38.       <primitive 191 7 private systemPortObj bytesArray msgSize>
  39. |
  40.    checkForPort
  41.       " See if the MsgPort Object is known to the AmigaOS: "
  42.       ^ <primtive 191 4 private> "Return either true or false."
  43. |
  44.    getNamedSystemPort: sysPortName
  45.       " Return an Integer that represents the System Port Name given: "
  46.       ^ <primitive 191 5 sysPortName>
  47. |
  48.    new: newPortName
  49.      " Allocate & initialize a new MsgPort for AmigaTalk: "
  50.      private  <- <primitive 191 6 newPortName>.
  51.      portName <- newPortName.
  52.      ^ self
  53. |
  54.    new
  55.      " Maybe this should be: printClassUsedInError "
  56.      ^ (self new: 'Default_AmigaTalk_MPort')
  57. ]
  58.